package ThreeSixZero;

import java.util.Scanner;

/**
 * @author Hang
 * @date 2022/9/24
 * @project AutumnOffer
 * @description
 **/
public class Solution1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[][] ans = new int[m][n];
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                ans[i][j] = sc.nextInt();
            }
        }
        int tsum = 0;
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(ans[i][j] > 0){
                    tsum++;
                }
            }
        }
        int csum = 0;
        for(int i=0;i<m;i++){
            int max = 0;
            for(int j=0;j<n;j++){
                if(ans[i][j] > max){
                    max = ans[i][j];
                }
            }
            csum += max;
        }
        int sum = 0;
        for(int i=0;i<n;i++){
            int max = 0;
            for(int j=0;j<m;j++){
                if(ans[j][i] > max){
                    max = ans[j][i];
                }
            }
            sum += max;
        }
        System.out.println((sum+csum+tsum)*2);
    }
}
